/**
 * 
 */
package leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhong
 *
 */
public class CamelcaseMatching {
	public List<Boolean> camelMatch(String[] queries, String pattern) {
		List<Boolean> res = new ArrayList<>();
		for (String string : queries) {
			res.add(match(string, pattern));
		}
		return res;
	}

	private static Boolean match(String string, String pattern) {
		int i = 0, j = 0;
		while (i < string.length() && j < pattern.length()) {
			if (string.charAt(i) == pattern.charAt(j)) {
				i++;
				j++;
			} else {
				if (Character.isUpperCase(string.charAt(i)))
					return false;
				i++;
			}
		}
		while (i < string.length()) {
			if (Character.isUpperCase(string.charAt(i)))
				return false;
			i++;
		}
		return j == pattern.length();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(match("FooBarTest", "FB"));
	}

}
